#include "../common.h"

class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0) {
            return false;
        }

		long n = x;
		long i = 1;
		int l = 0;

		while (n != 0) {
			n /= 10;
			i *= 10;
		}

		i /= 10;
		n = 0;

		int y = x;
		while (x != 0) {
			n += (x % 10) * i;
			if (INT_MIN > n || n > INT_MAX) {
				n = 0;
				break;
			}
			i /= 10;
			x /= 10;
		}

		return n == y;
    }
};